package org.ant.handler.typeChecking;

import java.util.ArrayList;
import java.util.Hashtable;

public class ClassDesc{
	String className;
	String Parent;
	ArrayList<VarDesc> vars;
	int memberVars;
	
	Hashtable<String,ArrayList<MethodDesc>> methods;
	
	public ClassDesc(String className, String parent) {
		super();
		this.className = className;
		Parent = parent;
		vars = new ArrayList<VarDesc>();
		methods = new Hashtable<String,ArrayList<MethodDesc>>();
		memberVars = 0;
	}
	
	public int getMemberVars(){
		return memberVars;
	}
	
	public void addVariable(VarDesc var){
		memberVars++;
		this.vars.add(var);
	}
	
	public void addMethod(MethodDesc m){
		ArrayList<MethodDesc> mList = this.methods.get(m.methodName);
		if(mList==null){
			mList = new ArrayList<MethodDesc>();
			mList.add(m);
			this.methods.put(m.methodName, mList);
		}else{
			mList.add(m);
		}
	}
	
	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	public String getParent() {
		return Parent;
	}

	public void setParent(String parent) {
		Parent = parent;
	}

	public ArrayList<VarDesc> getVars() {
		return vars;
	}

	public void setVars(ArrayList<VarDesc> vars) {
		this.vars = vars;
	}

	public Hashtable<String, ArrayList<MethodDesc>> getMethods() {
		return methods;
	}

	public MethodDesc getMethodByName(String methodName){
		return this.methods.get(methodName).get(0);
		
	}
	public void setMethods(Hashtable<String, ArrayList<MethodDesc>> methods) {
		this.methods = methods;
	}

	public VarDesc getVarByName(String id) {
		for (VarDesc v:this.vars){
			if (v.getName().equals(id)){
				return v;
			}
		}
		return null;
	}
	
}
